class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> hash; // 数组元素和下标
        for(int i = 0; i < nums.size(); ++i)
        {
            auto it = hash.find(target - nums[i]);
            if(it != hash.end())
                return {it->second, i};
            hash[nums[i]] = i;
        }
        return {-1, -1}; // 照顾编译器
    }
};